package hbr;

import static org.junit.Assert.assertTrue;
import java.awt.Color;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.testing.RobotTestBed;

/**
 * Test the attributes of KillBot to see if color change occurred.
 * 
 * @author Bryson Y. Hori
 */
public class TestColor extends RobotTestBed {
  boolean colorCheck = false;
  
  /**
   * Specifies that Corners and KillBot are to be matched up in this test case.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Corners,hbr.KillBot";
  }
  
  /**
   * This test runs for 10 round.
   *
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * Checks the attributes of Killbot.
   * 
   * @param event Info about the current state of the battle.
   */
  @Override
  public void onTurnEnded (TurnEndedEvent event) {
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    int bodyColor = robot.getBodyColor();
    int gunColor = robot.getGunColor();
    
    if ((bodyColor == Color.darkGray.getRGB()) && (gunColor == Color.lightGray.getRGB())) {
      colorCheck = true;
    }
  }
  
  /**
   * After the battle, check to see attributes of KillBot.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted (BattleCompletedEvent event) {
    assertTrue("Change KillBots attributes", colorCheck);
  }
}
